﻿
CREATE PROCEDURE [dbo].[OPM_ReturnOrderDetail_GetList]
(
	@ReturnOrderId  int,
	@ShowDeleted bit = 0
)

AS

	SELECT 		
		ROD.[Id],
		ROD.[ReturnOrderId],
		ROD.[ProductNumber],
		ROD.[ProductQty],
		ROD.[ReturnTypeId],
		ROD.[ReturnReasonXML],
		ROD.[OtherReasonChecked],
		ROD.[OtherReasonContent],
		ROD.[Deleted],
		ROD.[CreatedBy],
		ROD.[UpdatedBy],
		ROD.[CreatedOn],
		ROD.[UpdatedOn]
	    FROM dbo.[OPM_ReturnOrderDetail] ROD
        
        WHERE 
	    (ROD.[ReturnOrderId] = @ReturnOrderId) 
	    -- IF Show Hidden is true, then all records would be shown
	    -- IF Show Published, then display all records filter by t.Published = 1
	    AND    
	    (ROD.Deleted = 0 OR @ShowDeleted = 1)     
	    -- IF Show Deleted is true,  then all records would be shown
	    -- IF Show Deleted is false, then display all records filter by t.Deleted = 0
        
		ORDER BY ROD.Id ASC